#ifndef _STORAGE_HPP__
#define _STORAGE_HPP__ 1
#include <Types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/mman.h>
#include <FTSSException.hpp>
#include <unistd.h>
#define PAGES_FILE_CREATION_NUMBER 100
namespace FTSS {
	/**
	* @class inteface for storages
	*/
	class Storage{
	protected : 
		// file descriptors;
		INT_32 vector_empty_blocksHandler;
		INT_32 data_storageHandler;
		// file sizes
		INT_64 size_vector_file;
		INT_64 size_storage_nodes;
		// file data
		INT_64 *vector_data_mmap;
		CHAR_8 *storage_data_mmap;
		// length of data blocks
		INT_32 length_stack;
		INT_32 length_data;

	public : 
		/**
		  * @brief Constructor
		  * @param pStorageName - char pointer to storage file name
		  * @param pEmptyBloks - char pointer to storage white spaces file name
		  */
		Storage(CCHAR_P pStorageName, CCHAR_P pEmptyBlocks);

		/**
		  * @brief Destructor
		  */
		virtual ~Storage() throw();
	protected :
		/*
		 * @brief Open storage with create file and write headers
		 */
		void OpenStorage(CCHAR_P pFilename, const INT_32 flag);
		/**
		  * @brief if file size isn't enough add size and remmap it to RAM
		  * @param file descriptor
		  * @return 0 if success, -1 if something wrong 
		  */
		INT_32 ReMMAP(INT_32 descriptor);
	};
}

#endif
